<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>外部用户登录</title>
		<!-- IE -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<!-- 设置 viewport -->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- 兼容国产浏览器的高速模式 -->
		<meta name="renderer" content="webkit">
		<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
		<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.7-dist/css/bootstrap.css" />
		<link rel="stylesheet" type="text/css" href="../lib/bootstrapvalidator/dist/css/bootstrapValidator.css" />
		<style type="text/css">
			html {
				width: 100vw;
				height: 100vh;
			}
			
			body {
				width: 100%;
				height: 100%;
				background: url(../image/2.jpg) no-repeat;
				background-size: cover;
				position: relative;
			}
			
			.loginBox {
				width: 400px;
				height: 360px;
				background: #fff;
				position: absolute;
				margin: -200px -180px;
				top: 50%;
				left: 50%;
			}
			
			#form .form-group {
				width: 340px;
				margin: 0 auto;
				margin-top: 40px;
			}
		</style>
	</head>

	<body>
		<div class="loginBox">
			<form action="" class="form" id="form">
				<div class="school-title text-center" style="padding-top: 20px;">
					<h2>内部系统</h2>
				</div>
				<div class="form-group">
					<label class="sr-only" for="account">账号</label>
					<div class="input-group">
						<div class="input-group-addon">
							<img src="../img/login/account.png" />
						</div>
						<input type="text" class="form-control" id="account" placeholder="请输入用户账号" name="account" value="VRONE">
					</div>
				</div>
				<div class="form-group">
					<label class="sr-only" for="password">密码</label>
					<div class="input-group">
						<div class="input-group-addon">
							<img src="../img/login/password.png" />
						</div>
						<input type="text" class="form-control" id="password" placeholder="请输入用户密码" name="password" value="VRONE">
					</div>
				</div>
				<!--<div class="form-group" style="margin-top: 20px;">
				    <div class="">
				      <div class="checkbox">
				        <label>
				          <input type="checkbox"> 记住密码
				        </label>
				      </div>
				    </div>
				</div>-->
				<input type="hidden" name="school" id="school" value="0" />
				<div class="form-group" style="margin-top: 40px;">
					<button type="button" class="btn btn-primary  btn-block btn-save">登录</button>
				</div>
			</form>
		</div>

		<script src="../lib/jquery/1.9.1/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="../lib/bootstrap-3.3.7-dist/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
		<script src="../lib/layer/2.4/layer.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common/jsrsasign-all-min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common/crypto-js.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common/jquery.myPlugIn_v1.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common/localstorage-ie.js" type="text/javascript" charset="utf-8"></script>
		<script src="../lib/bootstrapvalidator/dist/js/bootstrapValidator.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(document).ready(function() {

				$('#form')
					.bootstrapValidator({
						message: '这个值是无效的',
						feedbackIcons: {
							valid: 'glyphicon glyphicon-ok',
							invalid: 'glyphicon glyphicon-remove',
							validating: 'glyphicon glyphicon-refresh'
						},
						fields: {							
							account: {
								message: '账号是无效的',
								validators: {
									notEmpty: {
										message: '账号是必需的，不能是空的'
									},
									stringLength: {
										min: 3,
										max: 20,
										message: '账号必须大于3，小于20个字符'
									},
									regexp: {
										regexp: /^[a-zA-Z0-9_\.]+$/,
										message: '账号只能由字母、数字、点和下划线组成'
									},
//									different: {
//										field: 'password',
//										message: '账号和密码不可能是相同的'
//									}
								}
							},
							
							password: {
								validators: {
									notEmpty: {
										message: '密码是必需的，不能是空的'
									},	
									stringLength: {
										min: 3,
										max: 20,
										message: '密码必须大于3，小于20个字符'
									},
									regexp: {
										regexp: /^[a-zA-Z0-9_\.]+$/,
										message: '密码只能由字母、数字、点和下划线组成'
									},
//									different: {
//										field: 'account',
//										message: '密码不可能与账号相同'
//									}
								}
							},
							
						}
					})
					.on('success.form.bv', function(e) {
						// 阻止表单提交
						e.preventDefault();
						// 获得表单实例
						var $form = $(e.target);
						// 得到BootstrapValidator实例
						var bv = $form.data('bootstrapValidator');
						console.log(bv);
						// 使用Ajax提交表单数据
						
						fnAjax.method_login(
							url_join("admin/auth/login"),
							$form.serialize(),
							"post",
							function(data){
								console.log(data);
								localStorage.setItem("token",data.data.token);
								layer.msg("登陆成功",{time:1500},function(){
									window.location.href = "index.html";
								});
							}
						);
					});
				// 手动验证表单
				$('.btn-save').click(function() {
					$('#form').bootstrapValidator('validate');
				});

				$(window).keyup(function(event){
					if(event.keyCode == "13") {
						$(".btn-save").trigger("click");
					}
                    // https://gitee.com/vincent2117/library.git
				});
			});
		</script>
	</body>

</html>